package elijah.base.net;


import android.content.Context;

import com.lxj.xpopup.XPopup;

import elijah.base.excetion.ExceptionHandler;
import elijah.base.utils.Toasts;


public abstract class BaseObserver<T> extends BaseProgressObserver<T> {

    public BaseObserver(Context context) {
        super(context);
    }

    public BaseObserver(Context context, String content) {
        super(context, content);
    }

    public BaseObserver(boolean showDialog) {
        super(showDialog);
    }

    public BaseObserver(String content) {
        super(content);
    }

    public BaseObserver(Context context, boolean showDialog) {
        super(context, showDialog);
    }

    @Override
    public void customerDialog(XPopup.Builder dialogBuilder) {
        super.customerDialog(dialogBuilder);
    }

    @Override
    public void onSuccess(T t) {
        super.onSuccess(t);
        try {
            result(t);
        } catch (final Exception e) {
            e.printStackTrace();
            Toasts.showErrorToastAsync(ExceptionHandler.handle(e).toString());
        }
    }

    public abstract void result(T t) throws Exception;

}
